#include "browserbuttons.h"

BrowserButtons::BrowserButtons(QWidget *parent) :
    QToolBar(parent)
{
    //Frame definition
    setMinimumHeight(48);
    setMaximumHeight(48);

    //Buttons
    //prev
    tbPrev=new QToolButton();
    tbPrev->setDisabled(true);
    //up
    tbUp=new QToolButton();
    //next
    tbNext=new QToolButton();
    tbNext->setDisabled(true);
    //home
    tbHome=new QToolButton();

    //view
    tbView=new QToolButton();

    //fullscreen
    tbFull=new QToolButton();
    tbFull->setCheckable(true);

    addWidget(tbPrev);
    addWidget(tbUp);
    addWidget(tbNext);
    addWidget(tbHome);
    //setLayout(layout);

}

//Changes some sizes for being displayed on mobile devices
void BrowserButtons::setMobileGUI(){

    //Use 48px buttons
    tbPrev->setIcon(QIcon(":/icons48/prev"));
    tbPrev->setIconSize(QSize(48,48));
    tbUp->setIcon(QIcon(":/icons48/up"));
    tbUp->setIconSize(QSize(48,48));
    tbNext->setIcon(QIcon(":/icons48/next"));
    tbNext->setIconSize(QSize(48,48));
    tbHome->setIcon(QIcon(":/icons48/home"));
    tbHome->setIconSize(QSize(48,48));
    tbView->setIcon(QIcon(":/icons48/icon-view"));
    tbView->setIconSize(QSize(48,48));
    tbFull->setIcon(QIcon(":/icons48/fullscreen"));
    tbFull->setIconSize(QSize(48,48));

    //tbPrev->setStyleSheet("QToolBar {padding: 0px; background-color: red;}");
    tbPrev->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed);
    tbUp->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed);
    tbNext->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed);
    tbHome->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed);
}

//Adds some extra buttons for desktop
void BrowserButtons::setDesktopGUI(){

    //Adding some more buttons for desktop
    addSeparator();
    //addWidget(tbFull);
    addWidget(tbView);

    //Use 32px buttons
    tbPrev->setIcon(QIcon(":/icons32/prev"));
    tbPrev->setIconSize(QSize(32,32));
    tbUp->setIcon(QIcon(":/icons32/up"));
    tbUp->setIconSize(QSize(32,32));
    tbNext->setIcon(QIcon(":/icons32/next"));
    tbNext->setIconSize(QSize(32,32));
    tbHome->setIcon(QIcon(":/icons32/home"));
    tbHome->setIconSize(QSize(32,32));
    tbView->setIcon(QIcon(":/icons32/icon-view"));
    tbView->setIconSize(QSize(32,32));
    tbFull->setIcon(QIcon(":/icons32/fullscreen"));
    tbFull->setIconSize(QSize(32,32));

    //On desktop we show a text under tool buttons
    tbPrev->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
    tbUp->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
    tbNext->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
    tbHome->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
    tbView->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
    tbFull->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
    tbPrev->setText(tr("Back"));
    tbUp->setText(tr("Up"));
    tbNext->setText(tr("Next"));
    tbHome->setText(tr("Home"));
    tbView->setText(tr("View"));
    tbFull->setText(tr("Maximmize"));

    //Exit button
    tbExit=new QToolButton();
    tbExit->setIcon(QIcon(":/icons32/exit"));
    tbExit->setIconSize(QSize(32,32));
    /*
    QFrame *stretch= new QFrame();
    stretch->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed);
    addWidget(stretch);
    addWidget(tbExit);*/
}
